package handin06;

import java.util.ArrayList;

/**
 * VendingMachine tester
 * @author Peter Tolstrup Aagesen, ptaa@itu.dk
 *
 */
public class VendingMachineTester {
	
	static void printValuableList(ArrayList<Valuable> valueList)
	{
		for(Valuable valueObject: valueList)
		{
			System.out.println(valueObject.toString());
		}
	}
	
	public static void main(String[] args) {
		VendingMachine machine = new VendingMachine();
		//Test to string
		System.out.println(machine.toString());
		System.out.println();
		
		//Test coins
		System.out.println("COIN TEST");
		machine.insertCoin(new Dime());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		machine.insertCoin(new Dollar());
		machine.insertCoin(new Quarter());
		machine.insertCoin(new Dime());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		System.out.println(machine.toString());
		System.out.println();
		
		//Test products
		System.out.println("PRODUCT TEST");
		machine.insertCoin(new Dollar());
		ArrayList<Valuable> valueList = machine.dispenceProduct(ProductType.APPLE);
		printValuableList(valueList);
		System.out.println();
		
		machine.insertCoin(new Dollar());
		machine.insertCoin(new Dollar());
		valueList = machine.dispenceProduct(ProductType.COLA);
		printValuableList(valueList);
		System.out.println();
		
		System.out.println(machine.toString());
		System.out.println();
		
		//Test supplier
		System.out.println("SUPPLIER TEST");
		int counter = 4;
		while(counter > 0)
		{
			machine.insertCoin(new Dollar());
			machine.dispenceProduct(ProductType.APPLE);
			System.out.println(machine.toString());
			System.out.println();
			counter --;
		}
		counter = 5;
		while(counter > 0)
		{
			machine.insertCoin(new Dollar());
			machine.dispenceProduct(ProductType.COLA);
			System.out.println(machine.toString());
			System.out.println();
			counter --;
		}
		
		//Test vendingMachine.giveChange
		System.out.println("TEST CHANGES");
		machine.insertCoin(new Dime());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		System.out.println(machine.toString());
		ArrayList<Coin> coins = machine.giveChange();
		System.out.println(coins.toString());
		System.out.println(machine.toString());
		System.out.println();
		
		//Not enough money test
		System.out.println("TEST NOT ENOUGH MONEY");
		machine.insertCoin(new Dime());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		machine.insertCoin(new Nickel());
		machine.insertCoin(new Penny());
		valueList = machine.dispenceProduct(ProductType.COLA);
		printValuableList(valueList);
		System.out.println();
	}
}
